#include <iostream>
#include <cmath>
using namespace std;
const int N = 30;
int arr[N];
int q[N];
int n, k, count;
bool IsPrime(int x)
{
    if (x < 2)
        return false;
    for (int i = 2; i <= x / i; i++)
    {
        if (x % i == 0)
            return false;
    }
    return true;
}

void dfs(int x, int start)
{
    if (x > k)
    {
        int sum = 0;
        for (int i = 1; i <= k; i++)
        {
            sum += q[i];
        }
        if (IsPrime(sum))
        {
            count++;
        }
        return;
    }
    for (int i = start; i <= n; i++)
    {
        q[x] = arr[i];
        dfs(x + 1, i + 1);
        q[x] = 0;
    }
}
int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        cin >> arr[i];
    }
    dfs(1, 1);
    cout << count << endl;
    return 0;
}